<?php
session_start();
isLogin();

if(isset($_POST["button"])){
	if($_POST['search']&&$_POST['replace']){
		$search=$_POST['search'];
		$replace=$_POST['replace'];
		if($_POST['dbtable']=='t1'){
			$sql="update ".$prefix."article set content=REPLACE(content,'".addslashes($search)."','".addslashes($replace)."')";
		}elseif($_POST['dbtable']=='t2'){
			$sql="update ".$prefix."article set description=REPLACE(description,'".$search."','".$replace."')";
		}elseif($_POST['dbtable']=='t3'){
			$sql="update ".$prefix."shoplist set s_clickurl=REPLACE(s_clickurl,'".$search."','".$replace."')";
		}elseif($_POST['dbtable']=='t4'){
			$sql="update ".$prefix."haodian set h_link =REPLACE(h_link ,'".$search."','".$replace."')";
		}elseif($_POST['dbtable']=='t5'){
			$sql="update ".$prefix."product set p_link=REPLACE(p_link ,'".$search."','".$replace."')";
		}
		if(mysql_query($sql)){
			reload_js("替换成功","index.php?cmd=replace");
		}else{
			reload_js("程序出错，请联系相关技术人员进行修正。","index.php?cmd=replace");
		}
	}
}
?>
<script language="javascript" src="<?php echo $website;?>/templates/<?php echo $moban;?>/js/common.js"></script>
<script language="javascript">
changeWebTitle('批量替换管理');
</script>
<div class="ContentRight">
    <div class="ContentRightTop">
      <div class="BarLeft"></div>
      <div class="ContentRightTopText">批量替换管理</div>
      <div class="BarRight"></div>
      <div class="Cal"></div>
    </div>
    <div class="ContentRightBox">
    <form action="" method="post" name="repform">
      <table width="100%" cellpadding="0" class="Table1" bordercolor="#4ab902" border="1" cellspacing="0">
        <tr>
          <td width="22%" height="25" align="right">替换表：</td>
          <td width="78%">
          <select name="dbtable" id="dbtable">
          <option value="t1">文章-内容</option>
          <option value="t2">文章-描述</option>
          <option value="t3">店铺-链接</option>
          <option value="t4">好店推荐-链接</option>
          <option value="t5">首页商品-链接</option>
          </select></td>
        </tr>
        <tr>
          <td height="25" align="right">查找：</td>
          <td><input name="search" type="text" id="search" size="50"></td>
        </tr>
        <tr>
          <td height="25" align="right">替换：</td>
          <td><input name="replace" type="text" id="replace" size="50"></td>
        </tr>
        <tr>
          <td height="25" align="right">&nbsp;</td>
          <td><input type="submit" name="button" id="button" value="开始替换"></td>
        </tr>
        <tr>
          <td height="25" align="right">版权所有：</td>
          <td><a href="http://www.fengsh8.com" target="_blank">风尚淘客程序</a></td>
        </tr>
      </table>
      </form>
</div>
    <div class="Cal"></div>
</div>